<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>员工列表</title>
  <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.18.0/axios.min.js"></script>
  <style>
    #app {
      max-width: 1200px;
      margin: 0 auto;
      padding: 20px;
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
      gap: 25px;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    .employee-card {
      width: 100%;
      background-color: #ffffff;
      border-radius: 12px;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
      padding: 20px;
      transition: all 0.3s ease;
      display: flex;
      flex-direction: column;
      align-items: center;
      text-align: center;
      position: relative;
      overflow: hidden;
    }

    .employee-card::before {
      content: '';
      position: absolute;
      top: 0;
      left: 0;
      width: 100%;
      height: 5px;
      background: linear-gradient(90deg, #4facfe 0%, #00f2fe 100%);
    }

    .employee-card:hover {
      transform: translateY(-5px);
      box-shadow: 0 12px 20px rgba(0, 0, 0, 0.12);
    }

    .employee-avatar {
      width: 100px;
      height: 100px;
      border-radius: 50%;
      object-fit: cover;
      border: 4px solid #f0f7ff;
      margin-bottom: 15px;
      transition: transform 0.3s ease;
    }

    .employee-card:hover .employee-avatar {
      transform: scale(1.05);
    }

    .employee-name {
      font-size: 1.2rem;
      font-weight: 600;
      color: #2c3e50;
      margin: 5px 0;
    }

    .employee-details {
      width: 100%;
      margin-top: 10px;
      padding-top: 10px;
      border-top: 1px solid #f1f5f9;
    }

    .employee-detail {
      font-size: 0.9rem;
      color: #64748b;
      margin: 6px 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .employee-detail i {
      margin-right: 6px;
      color: #4facfe;
      font-size: 0.8rem;
    }

    .employee-gender.male i {
      color: #3b82f6;
    }

    .employee-gender.female i {
      color: #ec4899;
    }
  </style>
</head>
<body>
<div id="app">
  <div v-for="(employee, index) in employees" :key="index" class="employee-card">
    <img :src="employee.avatar" :alt="`${employee.name}的头像`" class="employee-avatar">
    <div class="employee-name">{{ employee.name }}</div>
    <div class="employee-details">
      <div class="employee-detail employee-gender" :class="employee.gender.toLowerCase()">
        <i class="fas" :class="employee.gender === '男' ? 'fa-mars' : 'fa-venus'"></i>
        {{ employee.gender}}
      </div>
      <div class="employee-detail">
        <i class="fas fa-age"></i>
        {{ employee.age }}岁
      </div>
      <div class="employee-detail">
        <i class="fas fa-calendar-alt"></i>
        入职日期: {{ employee.hire_date }}
      </div>
    </div>
  </div>
</div>

<script>
  new Vue({
    el: '#app',
    data: {
      employees: []
    },
    mounted(){
      axios
              .get('/employee/selectAll')
              .then(response => (this.employees = response.data))
              .catch(function (error) { // 请求失败处理
                console.log(error);
              });
    }
  });
</script>
</body>
</html>
